-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore elementwise min/max on SIMD, with explicit naming. #24136
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…unctions. Having these as free functions causes expression too complex issues due to overload vis-a-vis min<Collection>. There are (at least) three plausible solutions: 1. Fix the typechecker. This is infeasable in the short term; or more precisely, we do not know how much work is involved. 2. Give these operations different names. Candidates discussed with core team include "pointwiseMin", "elementwiseMin", "lanewiseMin"; these all suffer from the flaw that when someone writes "min" in a SIMD context, they are essentially always looking for either the horizontal minimum (reduction) on a single vector or--more often--the lanewise minimum of two vectors (this operation). It would be odd to give the operation that people actually want the unnecessarily verbose name. 3. Make these operations static; this is, in effect, a different name, but it's one which frequently allows eliding the qualifier: let x = v + .min(v, w) This isn't perfect; you will still need to spell out SIMD4.min( ) fairly often, but that's more concise than any of the proposed alternatives, and at least allows elision some of the time. Also, if you squint, you can pretend that the "." prefix is like ".<" and ".&" and indicates lanewise operation.
@swift-ci please test |
@swift-ci please test source compatibility |
stephentyrone
changed the title
Restore elementwise min/max on SIMD, but as statics.
Restore elementwise min/max on SIMD, with explicit naming.
Apr 24, 2019
@swift-ci please test source compatibility |
Co-Authored-By: stephentyrone <stephentyrone@gmail.com>
@swift-ci please test |
Build failed |
Build failed |
Linux failure unrelated (base breakage). |
@swift-ci please smoke test linux |
stephentyrone
added a commit
to stephentyrone/swift
that referenced
this pull request
May 14, 2019
…#24136) * Restore elementwise min/max on SIMD, but as statics instead of free functions. Having these as free functions causes expression too complex issues due to overload vis-a-vis min<Collection>. There are (at least) three plausible solutions: 1. Fix the typechecker. This is infeasable in the short term; or more precisely, we do not know how much work is involved. 2. Give these operations different names. Candidates discussed with core team include "pointwiseMin", "elementwiseMin", "lanewiseMin"; these all suffer from the flaw that when someone writes "min" in a SIMD context, they are essentially always looking for either the horizontal minimum (reduction) on a single vector or--more often--the lanewise minimum of two vectors (this operation). It would be odd to give the operation that people actually want the unnecessarily verbose name. 3. Make these operations static; this is, in effect, a different name, but it's one which frequently allows eliding the qualifier: let x = v + .min(v, w) This isn't perfect; you will still need to spell out SIMD4.min( ) fairly often, but that's more concise than any of the proposed alternatives, and at least allows elision some of the time. Also, if you squint, you can pretend that the "." prefix is like ".<" and ".&" and indicates lanewise operation.
stephentyrone
added a commit
that referenced
this pull request
May 15, 2019
* Restore elementwise min/max on SIMD, with explicit naming. (#24136) * Restore elementwise min/max on SIMD, but as statics instead of free functions. Having these as free functions causes expression too complex issues due to overload vis-a-vis min<Collection>. There are (at least) three plausible solutions: 1. Fix the typechecker. This is infeasable in the short term; or more precisely, we do not know how much work is involved. 2. Give these operations different names. Candidates discussed with core team include "pointwiseMin", "elementwiseMin", "lanewiseMin"; these all suffer from the flaw that when someone writes "min" in a SIMD context, they are essentially always looking for either the horizontal minimum (reduction) on a single vector or--more often--the lanewise minimum of two vectors (this operation). It would be odd to give the operation that people actually want the unnecessarily verbose name. 3. Make these operations static; this is, in effect, a different name, but it's one which frequently allows eliding the qualifier: let x = v + .min(v, w) This isn't perfect; you will still need to spell out SIMD4.min( ) fairly often, but that's more concise than any of the proposed alternatives, and at least allows elision some of the time. Also, if you squint, you can pretend that the "." prefix is like ".<" and ".&" and indicates lanewise operation. * Really remove static min and max on simd. One slipped through. (#24283)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Having these as free functions causes expression too complex issues due to overload vis-a-vis min. There are (at least) three plausible solutions:
Fix the typechecker. This is infeasable in the short term; or more precisely, we do not know how much work is involved.
Give these operations different names. Candidates discussed with core team include "pointwiseMin", "elementwiseMin", "lanewiseMin"; these all suffer from the flaw that when someone writes "min" in a SIMD context, they are essentially always looking for either the horizontal minimum (reduction) on a single vector or--more often--the lanewise minimum of two vectors (this operation). It would be odd to give the operation that people actually want the unnecessarily verbose name.
Make these operations static; this is, in effect, a different name, but it's one which frequently allows eliding the qualifier:
let x = v + .min(v, w)
After considerable back-and-forth discussion with core, we settled on
pointwiseMin
andpointwiseMax
. These aren't perfect, but they are explicit, which is worth a lot.This rounds out SE-0251.